import pytest
import requests
from 接口自动化.case.DButils import *
from 接口自动化.send.Send import Send
from 接口自动化.utils.read_yaml import read_yaml
class TestBankcard:

    @pytest.mark.parametrize( "args" , read_yaml("../data/addbankcard.yaml"))
    def test_addbankcard(self,args):

        name = args["username"]
        pwd= args["pwd"]
        session  = requests.session()
        se = Send()
        login = se.send_login(session,name,pwd)
        print(login["body"]["code"])

        cardbank = args["cardbank"]
        type= args["type"]
        cardnum = args["cardnum"]
        exp = args["exp"]
        result = se.send_addbankcard(session,cardbank,type,cardnum)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)

    @pytest.mark.parametrize("args", read_yaml("../data/updatebankcard.yaml"))
    def test_updatebankcard(self, args):
        name = args["username"]
        pwd = args["pwd"]
        session = requests.session()
        se = Send()
        login = se.send_login(session, name, pwd)
        print(login["body"]["code"])

        id =args["id"]
        cardbank = args["cardbank"]
        type = args["type"]
        cardnum = args["cardnum"]
        exp = args["exp"]
        result = se.send_updatebankcard(session,id, cardbank, type, cardnum)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)

    @pytest.mark.parametrize("args", read_yaml("../data/addbankcard.yaml"))
    def test_addbankcard(self, args):
        name = args["username"]
        pwd = args["pwd"]
        session = requests.session()
        se = Send()
        login = se.send_login(session, name, pwd)
        print(login["body"]["code"])

        cardbank = args["cardbank"]
        type = args["type"]
        cardnum = args["cardnum"]
        exp = args["exp"]
        result = se.send_addbankcard(session, cardbank, type, cardnum)

        assert result["code"] == 200 and result["body"]["code"] == exp
        #
        # sql = "update user set password= %s where username  = %s"
        # param = ["e10adc3949ba59abbe56e057f20f883e","lisi"]
        # update(sql, param)